import { appendFileSync, writeFileSync } from "fs";
import Channel from "./channel/channel";

let channel = new Channel(8, false, true, {
    port: 10000,
    host: "0.0.0.0"
}, () => {
    console.log("隧道开始运行");
});

channel.regChannelAllConnected(() => {
    channel.regDataRecive((refPort, data) => {
        if(refPort == 10000)
        {
            console.log("1");
            appendFileSync("1.flv", data)
        }else if(refPort == 10001)
        {
            console.log("2");
            appendFileSync("2.flv", data)

        }else if(refPort == 10002)
        {
            console.log("3");
            appendFileSync("3.flv", data)

        }else if(refPort == 10003)
        {
            console.log("4");
            appendFileSync("4.flv", data)
            
        }else if(refPort == 10004)
        {
            console.log("5");
            appendFileSync("5.flv", data)

        }else 
        {
            console.log("未识别的数据丢弃");
        }
    });
});